package com.rxmvp.rxmvpdemo.base.mvp;

import com.rxmvp.rxmvpdemo.base.BaseActivity;

import javax.inject.Inject;

/**
 * 使用presenter的activity需要继承该类，负责获取presenter的实例，并且处理presenter的生命周期，
 *
 * 作者： huangRZ on 2017/1/21. 15:04
 * 邮箱：917647409@qq.com
 */
public class BasePresenterActivity<T extends IBasePresenter> extends BaseActivity {

    //继承了IBasePresenter的任意Presenter对象
    @Inject
    protected T mPresenter;

    @Override
    protected void onResume() {
        super.onResume();
        if (mPresenter != null) {
            mPresenter.onStart();
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (mPresenter != null) {
            mPresenter.onStop();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.onDestroy();
        }
    }

}
